/*
 * ImportadorArquivo.java
 *
 * Created on 12 de Julho de 2007, 15:22
 */
package br.com.cpqd.ssar.gerenciador.gui;

import java.io.File;
import javax.swing.JFileChooser;
import javax.swing.JFrame;

/**
 *
 * @author  Igor José
 */
public class ImportadorArquivo extends javax.swing.JFrame {

    private File sf;
    private String diretorio;

    /** Creates new form ImportadorArquivo */
    public ImportadorArquivo() {
        initComponents();
        int option = jFileChooser1.showOpenDialog(new JFrame());
        // User selected OPEN
        if (option == JFileChooser.APPROVE_OPTION) {
            // sf is an string that indicate the selected file
            sf = jFileChooser1.getSelectedFile();
            diretorio = new String(jFileChooser1.getCurrentDirectory().getAbsolutePath().toString());

        } // User selected CANCEL
        else if (option == JFileChooser.CANCEL_OPTION) {
        }
    }

    public String getDiretorio() {
        try {
            return diretorio;
        } catch (Exception e) {
            System.out.println("Error: " + e);
            return null;
        }
    }


    public String getNome() {
        try {
            return sf.getName();
        } catch (Exception e) {
            System.out.println("Error: " + e);
            return null;
        }
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jFileChooser1 = new javax.swing.JFileChooser();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

        jFileChooser1.setAcceptAllFileFilterUsed(false);
        jFileChooser1.setBackground(new java.awt.Color(231, 240, 250));
        jFileChooser1.setDialogTitle("Importador STL");
        jFileChooser1.setFileFilter(new javax.swing.filechooser.FileFilter() {
            public boolean accept(File f) {
                return f.getName().toLowerCase().endsWith("") || f.isDirectory();
            }
            public String getDescription() {
                return "Arquivos de Malha do Gid)";
            }
        });
        jFileChooser1.setFileSelectionMode(javax.swing.JFileChooser.FILES_AND_DIRECTORIES);

        org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(layout.createSequentialGroup()
                .addContainerGap()
                .add(jFileChooser1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(layout.createSequentialGroup()
                .addContainerGap()
                .add(jFileChooser1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JFileChooser jFileChooser1;
    // End of variables declaration//GEN-END:variables
}
